package com.lvhaosb.newpneumonia;

import com.lvhaosb.newpneumonia.POJO.po.Country;
import com.lvhaosb.newpneumonia.POJO.po.DomesticEpidemic;
import com.lvhaosb.newpneumonia.service.CountryService;
import com.lvhaosb.newpneumonia.spider.SpiderPipeline;
import com.lvhaosb.newpneumonia.spider.SpiderProcessor;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.scheduler.BloomFilterDuplicateRemover;
import us.codecraft.webmagic.scheduler.QueueScheduler;

public class MockTomcat {
    public static void main(String[] args) {
        /**
         * spring
         */
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        CountryService countryService = (CountryService) context.getBean("countryServiceImpl");

        /*String url = "https://voice.baidu.com/act/newpneumonia/newpneumonia/";
        Spider.create(new SpiderProcessor())
                .addUrl(url)
                .setScheduler(new QueueScheduler().setDuplicateRemover(new BloomFilterDuplicateRemover(10000)))
                .thread(10)
                .addPipeline((SpiderPipeline)context.getBean("spiderPipeline"))
                .run();*/

        /**
         * mybatis
         */
        /*try {
            SqlSessionFactory factory = new SqlSessionFactoryBuilder()
                    .build(Resources.getResourceAsStream("mybatis-config.xml"));
            SqlSession session = factory.openSession();
            *//*
             * List<User> users = session.selectList("queryAllUser"); for (User user :
             * users) { System.out.println(user.getUsername()); }
             *//*
            DomesticEpidemic domesticEpidemic = session.selectOne("selectByTimeNewest");
            System.out.println(domesticEpidemic);

            session.commit();
            session.close();
        } catch (Exception e) {
            e.printStackTrace();
        }*/

    }


}
